<template>
  <scroll-view scroll-y enable-flex class="video_main" @scrolltolower=handleScrolltolower>
    <view class="item" v-for="item in videowp" :key="item.id" @click="handleGoVideo(item)">
      <image :src="item.img" mode="widthFix"></image>
    </view>
  </scroll-view>
</template>

<script>
  export default {
    props:{
      urlObj:Object
    },
    data() {
      return {
        videowp:[],
        hasMore:true
      }
    },
    watch: {
      urlObj(){
        this.videowp=[]
        this.getList()
      }
    },
    mounted() {
      this.getList()
    },
    methods: {
      getList(){
        this.request({
          url:this.urlObj.url,
          data:this.urlObj.params
        }).then(res=>{
          if (res.res.videowp===0) {
            this.hasMore=false
            return
          }
          this.videowp=[...this.videowp,...res.res.videowp]
        })
      },
      handleScrolltolower(){
        if (this.hasMore) {
          this.urlObj.params.skip+=this.urlObj.params.limit
          this.getList()
        }else{
          uni.showToast({
            title:"没有数据了",
            icon:"none"
          })
        }
      },
      handleGoVideo(item){
        //全局存储
        getApp().globalData.video=item
        //跳转
        //console.log(item);
        uni.navigateTo({
          url:"/pages/videoPlay/index"
        })
      }
    },
  }
</script>

<style lang="scss" scoped>
.video_main{
  display: flex;
  flex-wrap: wrap;
  height: calc(100vh - 36px);
  .item{
    width: 33.33%;
    padding: 5rpx;
    image{

    }
  }
}
</style>